﻿using System;
using System;
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using netDxf;
using netDxf.Blocks;
using netDxf.Collections;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Objects;
using netDxf.Tables;
using netDxf.Units;
using Attribute = netDxf.Entities.Attribute;
using Image = netDxf.Entities.Image;
using Point = netDxf.Entities.Point;
using Trace = netDxf.Entities.Trace;
using System.Threading;

namespace TestDxfDocument
{

    class Shellfacemillingcutter5
    {
        public static void _Shellfacemillingcutter5(Dictionary<string, Object> data)//细柄丝锥
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            refin.Linetype = Linetype.Dashed;
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            centre.Linetype = Linetype.DashDot;
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层

            //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);


            double scale = 1; //放大系数

            double a = 225;
            double b = 14;
            double c = 32;
            double d1 = 60;
            double d2 = 68;
            double d3 = 18;
            double d4 = 26;
            double d5 = 22;
            double d6 = 34;
            double d7 = 245;
            double e = 25.7;
            double H = 80;
            double D = 315;
            double kr = 75;
            double l = 32;



            //坐标
            Vector2 v1 = new Vector2(0, 0);
            Vector2 v2 = new Vector2(v1.X + H + 10, v1.Y);
            Vector2 v3 = new Vector2(v1.X + 6, v1.Y);
            Vector2 v43 = new Vector2(v3.X + H, v3.Y + D / 2);
            Vector2 v44 = fun.Polar(v43, (90 + kr) * pi / 180, H / 3);
            Vector2 v4 = new Vector2(v3.X, v44.Y - b / 2);
            Vector2 v5 = new Vector2(v4.X + H * 4 / 5, v4.Y);
            Vector2 v6 = fun.Polar(v5, (kr - 90) * pi / 180, b / 1.23);
            Vector2 v7 = new Vector2(v6.X, v6.Y * -1);
            Vector2 v8 = new Vector2(v5.X, v5.Y * -1);
            Vector2 v9 = new Vector2(v4.X, v4.Y * -1);
            Vector2 v11 = new Vector2(v3.X, v3.Y + Math.Pow(d1 / 2 * d1 / 2 - e / 2 * e / 2, 0.5));
            Vector2 v12 = new Vector2(v11.X + b, v11.Y);
            Vector2 v13 = new Vector2(v12.X, v3.Y + d7 / 2);
            Vector2 v14 = new Vector2(v11.X, v13.Y);
            Vector2 v15 = new Vector2(v12.X, v3.Y + d1 / 2);
            Vector2 v16 = new Vector2(v3.X + l, v15.Y);
            Vector2 v17 = new Vector2(v16.X, v3.Y + d2 / 2);
            Vector2 v18 = new Vector2(v6.X - H / 5, v17.Y);
            Vector2 v19 = new Vector2(v3.X, v3.Y - d1 / 2);
            Vector2 v20 = new Vector2(v16.X, v16.Y * -1);
            Vector2 v21 = new Vector2(v17.X, v17.Y * -1);
            Vector2 v22 = new Vector2(v18.X, v18.Y * -1);
            Vector2 v23 = new Vector2(v3.X, v3.Y - a / 5.2788);
            Vector2 v24 = new Vector2(v23.X + c, v23.Y);
            Vector2 v25 = new Vector2(v24.X, v24.Y + (d4 - d3) / 2);
            Vector2 v26 = new Vector2(v18.X, v25.Y);
            Vector2 v27 = new Vector2(v23.X, v23.Y - d3);
            Vector2 v28 = new Vector2(v24.X, v27.Y);
            Vector2 v29 = new Vector2(v25.X, v25.Y - d4);
            Vector2 v30 = new Vector2(v26.X, v29.Y);
            Vector2 v31 = new Vector2(v3.X, v3.Y - a / 2.87);
            Vector2 v32 = new Vector2(v28.X, v31.Y);
            Vector2 v33 = new Vector2(v32.X, v32.Y + (d6 - d5) / 2);
            Vector2 v34 = new Vector2(v30.X, v33.Y);
            Vector2 v35 = new Vector2(v31.X, v31.Y - d5);
            Vector2 v36 = new Vector2(v32.X, v35.Y);
            Vector2 v37 = new Vector2(v33.X, v33.Y - d6);
            Vector2 v38 = new Vector2(v34.X, v37.Y);
            Vector2 v39 = new Vector2(v6.X, v6.Y - b / 3);
            Vector2 v40 = new Vector2(v18.X, v39.Y - H / 3.473);
            Vector2 v41 = new Vector2(v39.X, v39.Y * -1);
            Vector2 v42 = new Vector2(v40.X, v40.Y * -1);
            Vector2 v45 = new Vector2(v43.X, v43.Y - H / 7.277);
            Vector2 v46 = new Vector2(v45.X - 4, v45.Y - 4);
            Vector2 v47 = new Vector2(v43.X, v43.Y * -1);
            Vector2 v48 = new Vector2(v44.X, v44.Y * -1);
            Vector2 v49 = new Vector2(v45.X, v45.Y * -1);
            Vector2 v50 = new Vector2(v46.X, v46.Y * -1);
            Vector2 v51 = new Vector2(v3.X, v3.Y + a / 2);
            Vector2 v52 = new Vector2(v51.X + b / 2.4, v51.Y + b / 2.4);
            Vector2 v53 = new Vector2(v52.X, v4.Y);
            Vector2 v54 = new Vector2(v23.X - 5, v23.Y - d3 / 2);
            Vector2 v55 = new Vector2(v2.X, v54.Y);
            Vector2 v56 = new Vector2(v54.X, v31.Y - d5 / 2);
            Vector2 v57 = new Vector2(v55.X, v56.Y);
            Vector2 v58 = new Vector2(v51.X, v51.Y * -1);
            Vector2 v59 = new Vector2(v52.X, v52.Y * -1);
            Vector2 v60 = new Vector2(v53.X, v53.Y * -1);

            Vector2 v61 = new Vector2(v2.X + D, v2.Y);
            Vector2 v62 = new Vector2(v61.X - D / 2 - 5, v61.Y);
            Vector2 v63 = new Vector2(v61.X + D / 2 + 5, v61.Y);
            Vector2 v64 = new Vector2(v61.X, v61.Y + D / 2 + 5);
            Vector2 v65 = new Vector2(v61.X, v61.Y - D / 2 - 5);
            Vector2 v66 = fun.Polar(v61, 135 * pi / 180, D / 2 + 5);
            Vector2 v67 = fun.Polar(v61, -45 * pi / 180, D / 2 - 5);
            Vector2 v68 = fun.Polar(v61, 45 * pi / 180, d7 / 2);
            Vector2 v69 = fun.Polar(v61, -135 * pi / 180, d7 / 2);
            Vector2 v70 = new Vector2(v61.X - e / 2, v12.Y);
            Vector2 v71 = new Vector2(v70.X, v61.Y + d7 / 2 - d7 / 25.69);
            Vector2 v72 = new Vector2(v71.X + e, v71.Y);
            Vector2 v73 = new Vector2(v72.X, v70.Y);
            Vector2 v74 = new Vector2(v73.X, v73.Y * -1);
            Vector2 v75 = new Vector2(v72.X, v72.Y * -1);
            Vector2 v76 = new Vector2(v71.X, v71.Y * -1);
            Vector2 v77 = new Vector2(v70.X, v70.Y * -1);
            Vector2 v78 = fun.Polar(v61, 135 * pi / 180, d7 / 2.619);
            Vector2 v79 = fun.Polar(v61, 45 * pi / 180, d7 / 2.619);
            Vector2 v80 = new Vector2(v79.X, v79.Y * -1);
            Vector2 v81 = new Vector2(v78.X, v80.Y);
            Vector2 v82 = fun.Polar(v61, 135 * pi / 180, d7 / 4.61);
            Vector2 v83 = fun.Polar(v61, 45 * pi / 180, d7 / 4.61);
            Vector2 v84 = new Vector2(v83.X, v83.Y * -1);
            Vector2 v85 = new Vector2(v82.X, v84.Y);
            Vector2 v86 = new Vector2(v61.X, v61.Y + d7 / 2);
            Vector2 v87 = new Vector2(v61.X, v61.Y - d7 / 2);




            //作图
            Line line1 = new Line(v1, v2);
            line1.Layer = centre;
            line1.Linetype = Linetype.DashDot;
            line1.LinetypeScale = 3;
            dxf.AddEntity(line1);

            LwPolyline line2 = new LwPolyline();
            line2.Vertexes.Add(new LwPolylineVertex(v4));
            line2.Vertexes.Add(new LwPolylineVertex(v5));
            line2.Vertexes.Add(new LwPolylineVertex(v6));
            line2.Vertexes.Add(new LwPolylineVertex(v7));
            line2.Vertexes.Add(new LwPolylineVertex(v8));
            line2.Vertexes.Add(new LwPolylineVertex(v9));
            line2.Vertexes.Add(new LwPolylineVertex(v4));
            fun.PolyFill(dxf, line2, 0.3, contour);

            LwPolyline line3 = new LwPolyline();
            line3.Vertexes.Add(new LwPolylineVertex(v14));
            line3.Vertexes.Add(new LwPolylineVertex(v13));
            line3.Vertexes.Add(new LwPolylineVertex(v12));
            line3.Vertexes.Add(new LwPolylineVertex(v11));
            fun.PolyFill(dxf, line3, 0.3, contour);

            LwPolyline line4 = new LwPolyline();
            line4.Vertexes.Add(new LwPolylineVertex(v15));
            line4.Vertexes.Add(new LwPolylineVertex(v16));
            line4.Vertexes.Add(new LwPolylineVertex(v20));
            line4.Vertexes.Add(new LwPolylineVertex(v19));
            fun.PolyFill(dxf, line4, 0.3, contour);

            LwPolyline line5 = new LwPolyline();
            line5.Vertexes.Add(new LwPolylineVertex(v18));
            line5.Vertexes.Add(new LwPolylineVertex(v17));
            line5.Vertexes.Add(new LwPolylineVertex(v21));
            line5.Vertexes.Add(new LwPolylineVertex(v22));
            fun.PolyFill(dxf, line5, 0.3, contour);

            LwPolyline line6 = new LwPolyline();
            line6.Vertexes.Add(new LwPolylineVertex(v23));
            line6.Vertexes.Add(new LwPolylineVertex(v24));
            line6.Vertexes.Add(new LwPolylineVertex(v28));
            line6.Vertexes.Add(new LwPolylineVertex(v27));
            fun.PolyFill(dxf, line6, 0.3, contour);

            LwPolyline line7 = new LwPolyline();
            line7.Vertexes.Add(new LwPolylineVertex(v26));
            line7.Vertexes.Add(new LwPolylineVertex(v25));
            line7.Vertexes.Add(new LwPolylineVertex(v29));
            line7.Vertexes.Add(new LwPolylineVertex(v30));
            fun.PolyFill(dxf, line7, 0.3, contour);

            LwPolyline line8 = new LwPolyline();
            line8.Vertexes.Add(new LwPolylineVertex(v31));
            line8.Vertexes.Add(new LwPolylineVertex(v32));
            line8.Vertexes.Add(new LwPolylineVertex(v36));
            line8.Vertexes.Add(new LwPolylineVertex(v35));
            fun.PolyFill(dxf, line8, 0.3, contour);

            LwPolyline line9 = new LwPolyline();
            line9.Vertexes.Add(new LwPolylineVertex(v34));
            line9.Vertexes.Add(new LwPolylineVertex(v33));
            line9.Vertexes.Add(new LwPolylineVertex(v37));
            line9.Vertexes.Add(new LwPolylineVertex(v38));
            fun.PolyFill(dxf, line9, 0.3, contour);

            LwPolyline line10 = new LwPolyline();
            line10.Vertexes.Add(new LwPolylineVertex(v39));
            line10.Vertexes.Add(new LwPolylineVertex(v40));
            line10.Vertexes.Add(new LwPolylineVertex(v42));
            line10.Vertexes.Add(new LwPolylineVertex(v41));
            line10.Vertexes[0].Bulge = Math.Tan(67 * pi / 180 / 4);
            line10.Vertexes[2].Bulge = Math.Tan(67 * pi / 180 / 4);
            fun.PolyFill(dxf, line10, 0.3, contour);

            LwPolyline line11 = new LwPolyline();
            line11.Vertexes.Add(new LwPolylineVertex(v46));
            line11.Vertexes.Add(new LwPolylineVertex(v45));
            line11.Vertexes.Add(new LwPolylineVertex(v43));
            line11.Vertexes.Add(new LwPolylineVertex(v44));
            fun.PolyFill(dxf, line11, 0.3, contour);

            LwPolyline line12 = new LwPolyline();
            line12.Vertexes.Add(new LwPolylineVertex(v50));
            line12.Vertexes.Add(new LwPolylineVertex(v49));
            line12.Vertexes.Add(new LwPolylineVertex(v47));
            line12.Vertexes.Add(new LwPolylineVertex(v48));
            fun.PolyFill(dxf, line12, 0.3, contour);

            Line line13 = new Line(v51, v52);
            line13.Layer = centre;
            line13.Linetype = Linetype.DashDot;
            line13.LinetypeScale = 3;
            dxf.AddEntity(line13);

            Line line14 = new Line(v52, v53);
            line14.Layer = centre;
            line14.Linetype = Linetype.DashDot;
            line14.LinetypeScale = 3;
            dxf.AddEntity(line14);

            Line line15 = new Line(v54, v55);
            line15.Layer = centre;
            line15.Linetype = Linetype.DashDot;
            line15.LinetypeScale = 3;
            dxf.AddEntity(line15);

            Line line16 = new Line(v56, v57);
            line16.Layer = centre;
            line16.Linetype = Linetype.DashDot;
            line16.LinetypeScale = 3;
            dxf.AddEntity(line16);

            Line line17 = new Line(v58, v59);
            line17.Layer = centre;
            line17.Linetype = Linetype.DashDot;
            line17.LinetypeScale = 3;
            dxf.AddEntity(line17);

            Line line18 = new Line(v59, v60);
            line18.Layer = centre;
            line18.Linetype = Linetype.DashDot;
            line18.LinetypeScale = 3;
            dxf.AddEntity(line18);

            LwPolyline line19 = new LwPolyline();
            line19.Vertexes.Add(new LwPolylineVertex(v70));
            line19.Vertexes.Add(new LwPolylineVertex(v71));
            line19.Vertexes.Add(new LwPolylineVertex(v86));
            line19.Vertexes.Add(new LwPolylineVertex(v72));
            line19.Vertexes.Add(new LwPolylineVertex(v73));
            line19.Vertexes[1].Bulge = Math.Tan(-63 * pi / 180 / 4);
            line19.Vertexes[2].Bulge = Math.Tan(-63 * pi / 180 / 4);
            fun.PolyFill(dxf, line19, 0.3, contour);

            LwPolyline line20 = new LwPolyline();
            line20.Vertexes.Add(new LwPolylineVertex(v74));
            line20.Vertexes.Add(new LwPolylineVertex(v75));
            line20.Vertexes.Add(new LwPolylineVertex(v87));
            line20.Vertexes.Add(new LwPolylineVertex(v76));
            line20.Vertexes.Add(new LwPolylineVertex(v77));
            line20.Vertexes[1].Bulge = Math.Tan(-63 * pi / 180 / 4);
            line20.Vertexes[2].Bulge = Math.Tan(-63 * pi / 180 / 4);
            fun.PolyFill(dxf, line20, 0.3, contour);

            Line line21 = new Line(v62, v63);
            line21.Layer = centre;
            line21.Linetype = Linetype.DashDot;
            line21.LinetypeScale = 3;
            dxf.AddEntity(line21);

            Line line22 = new Line(v64, v65);
            line22.Layer = centre;
            line22.Linetype = Linetype.DashDot;
            line22.LinetypeScale = 3;
            dxf.AddEntity(line22);

            Line line23 = new Line(v66, v67);
            line23.Layer = centre;
            line23.Linetype = Linetype.DashDot;
            line23.LinetypeScale = 3;
            dxf.AddEntity(line23);

            Line line24 = new Line(v68, v69);
            line24.Layer = centre;
            line24.Linetype = Linetype.DashDot;
            line24.LinetypeScale = 3;
            dxf.AddEntity(line24);

            fun.drawcircle(dxf, v61, d1 / 2, 0.3, contour);

            fun.drawcircle(dxf, v61, D / 2, 0.3, contour);

            fun.drawcircle(dxf, v78, d5 / 2, 0.3, contour);

            fun.drawcircle(dxf, v79, d5 / 2, 0.3, contour);

            fun.drawcircle(dxf, v80, d5 / 2, 0.3, contour);

            fun.drawcircle(dxf, v81, d5 / 2, 0.3, contour);

            fun.drawcircle(dxf, v82, d3 / 2, 0.3, contour);

            fun.drawcircle(dxf, v83, d3 / 2, 0.3, contour);

            fun.drawcircle(dxf, v84, d3 / 2, 0.3, contour);

            fun.drawcircle(dxf, v85, d3 / 2, 0.3, contour);

            fun.drawcircle(dxf, v61, Math.Pow(((v71.Y - v61.Y) * (v71.Y - v61.Y)) + (e / 2 * e / 2), 0.5), 0.3, centre);

            fun.drawcircle(dxf, v61, Math.Pow((v78.Y - v61.Y) * (v78.Y - v61.Y) + (v78.X - v61.X) * (v78.X - v61.X), 0.5), 0.3, centre);

            fun.drawcircle(dxf, v61, Math.Pow((v82.Y - v61.Y) * (v82.Y - v61.Y) + (v82.X - v61.X) * (v82.X - v61.X), 0.5), 0.3, centre);


            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v4));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v5));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v6));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v39));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v40));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v18));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v17));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v16));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v15));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v14));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v4));
            hatchpoly1.Vertexes[3].Bulge = Math.Tan(67 * pi / 180 / 4);
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 10, hline1, harc1, hatching);

            LwPolyline hatchpoly2 = new LwPolyline();
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v19));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v20));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v21));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v22));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v26));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v25));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v24));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v23));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v19));
            hatchpoly2.IsClosed = true;
            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            Arc[] harc2 = new Arc[100];
            int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)hatchpoly2.Explode()[i];
                }
                if (htype2[i] == "Arc")
                {
                    harc2[i] = (Arc)hatchpoly2.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype2, hnumst2, 45, 10, hline2, harc2, hatching);

            LwPolyline hatchpoly3 = new LwPolyline();
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v27));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v28));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v29));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v30));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v34));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v33));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v32));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v31));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v27));
            hatchpoly3.IsClosed = true;
            String[] htype3 = new String[100];
            Line[] hline3 = new Line[100];
            Arc[] harc3 = new Arc[100];
            int hnumst3 = hatchpoly3.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst3; i++)
            {
                htype3[i] = hatchpoly3.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype3[i] == "Line")
                {
                    hline3[i] = (Line)hatchpoly3.Explode()[i];
                }
                if (htype3[i] == "Arc")
                {
                    harc3[i] = (Arc)hatchpoly3.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype3, hnumst3, 45, 10, hline3, harc3, hatching);

            LwPolyline hatchpoly4 = new LwPolyline();
            hatchpoly4.Vertexes.Add(new LwPolylineVertex(v9));
            hatchpoly4.Vertexes.Add(new LwPolylineVertex(v35));
            hatchpoly4.Vertexes.Add(new LwPolylineVertex(v36));
            hatchpoly4.Vertexes.Add(new LwPolylineVertex(v37));
            hatchpoly4.Vertexes.Add(new LwPolylineVertex(v38));
            hatchpoly4.Vertexes.Add(new LwPolylineVertex(v42));
            hatchpoly4.Vertexes.Add(new LwPolylineVertex(v41));
            hatchpoly4.Vertexes.Add(new LwPolylineVertex(v7));
            hatchpoly4.Vertexes.Add(new LwPolylineVertex(v8));
            hatchpoly4.Vertexes.Add(new LwPolylineVertex(v9));
            hatchpoly4.Vertexes[5].Bulge = Math.Tan(67 * pi / 180 / 4);
            hatchpoly4.IsClosed = true;
            String[] htype4 = new String[100];
            Line[] hline4 = new Line[100];
            Arc[] harc4 = new Arc[100];
            int hnumst4 = hatchpoly4.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst4; i++)
            {
                htype4[i] = hatchpoly4.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype4[i] == "Line")
                {
                    hline4[i] = (Line)hatchpoly4.Explode()[i];
                }
                if (htype4[i] == "Arc")
                {
                    harc4[i] = (Arc)hatchpoly4.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype4, hnumst4, 45, 10, hline4, harc4, hatching);




            //标注

            double height = 5;
            double arrowsize = 1;
            double exline = 2;




            fun.dimrot1(dxf, v15, v19, 90, d1 / 2, 1, height, arrowsize, exline, "d1=" + d1, "", "");

            fun.dimrot1(dxf, v23, v27, 90, d1, 1, height, arrowsize, exline, "d3=" + d3, "", "");

            fun.dimrot1(dxf, v31, v35, 90, d1 / 2, 1, height, arrowsize, exline, "d5=" + d5, "", "");

            fun.dimrot1(dxf, v51, v58, 90, d1 * 3 / 2, 1, height, arrowsize, exline, "a=" + a, "", "");

            fun.dimrot1(dxf, v4, v9, 90, d1 * 2, 1, height, arrowsize, exline, "D1", "", "");

            fun.dimrot1(dxf, v4, v13, 0, d1, 1, height, arrowsize, exline, "b=" + b, "", "");

            fun.dimrot1(dxf, v4, v43, 0, d1, 1, height, arrowsize, exline, "H=" + H, "", "");

            fun.dimrot1(dxf, v43, v47, -90, d1 * 2, 1, height, arrowsize, exline, "D=" + D, "", "");

            fun.dimrot1(dxf, v18, v22, -90, d1, 1, height, arrowsize, exline, "d2=" + d2, "", "");

            fun.dimrot1(dxf, v26, v30, -90, d1 / 2, 1, height, arrowsize, exline, "d4=" + d4, "", "");

            fun.dimrot1(dxf, v34, v38, -90, d1, 1, height, arrowsize, exline, "d6=" + d6, "", "");

            fun.dimrot1(dxf, v9, v48, 180, d1 * 3 / 2, 1, height, arrowsize, exline, "c=" + c, "", "");

            fun.dimrot1(dxf, v86, v87, -90, D / 2 + c, 1, height, arrowsize, exline, "d7=" + d7, "", "");

            fun.dimrot1(dxf, v75, v76, 180, d1 * 3 / 2, 1, height, arrowsize, exline, "e=" + e, "", "");

            fun.jdbz1(dxf, new Line(v43, fun.Polar(v43, 90 * pi / 180, 0.1)), new Line(v43, fun.Polar(v43, (kr + 90) * pi / 180, 0.1)), 30, "kr", 5);

            fun.jdbz1(dxf, new Line(v61, fun.Polar(v61, 90 * pi / 180, 0.1)), new Line(v61, fun.Polar(v61, 45 * pi / 180, 0.1)), D / 2 + 6, "45°", 5);

            fun.jdbz1(dxf, new Line(v61, fun.Polar(v61, 90 * pi / 180, 0.1)), new Line(v61, fun.Polar(v61, 135 * pi / 180, 0.1)), D / 2 + 6, "45°", 5);






            //定义格式，路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);


        }

    }
}
